import { mapState } from 'vuex'

var data = {
    confirmBankShow: false,
    alertBankshow: false,
    detail: null
}

var vm = {
    data() {
        return data
    },
    computed: {
        ...mapState(['order'])
    },
    mounted() {
        if (this.order.orderId == null) {
            $router.replace('/system/neterror')
        }
    },
    methods: {
        confirmBankDo() {
            this.confirmBankShow = true
        },
        repayDo() {
            this.confirmBankShow = false
            $loading.show()
            $ajax.order.repay({
                userId: $store.state.user.userId,
                orderId: $store.state.order.orderId
            }).then(res => {
                var { code, msg } = res.data
                $toast.show(msg)
                if (code == 'S') {
                    $wxsdk.postLbs({
                        scene: 8,
                        mobile: $store.state.user.mobile,
                        userId: $store.state.user.userId
                    })
                    this.alertBankshow = true
                }
            }).catch(err => {
                $toast.show('网络异常，请稍后重试')
            })
        },
        cancaelRepayDo() {
            this.confirmBankShow = false
        },
        repaySuccessDo() {
            $router.replace('/loan/action')
        }
    },
    mixins: [$mixins.needLogin]
}

export default vm